package zhuyun.code.photoviews.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import zhuyun.code.photoviews.R

/**
 * @author: Administrator
 * @date: 2021/12/26
 */
class RecyclerViewAdapter(private val context:Context): RecyclerView.Adapter<RecyclerViewAdapter.PhotoViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PhotoViewHolder {
        val itemView = LayoutInflater.from(context).inflate(R.layout.item_photo_list_view,null)
        return PhotoViewHolder(
            itemView
        )
    }

    override fun getItemCount(): Int {
        return 10
    }


    override fun onBindViewHolder(holder: PhotoViewHolder, position: Int) {
        holder.imageView.setImageResource(R.drawable.yangme)
        holder.index.text = "${position+1}"
    }

    class PhotoViewHolder(private val mItemView: View):RecyclerView.ViewHolder(mItemView){
        val imageView: ImageView = mItemView.findViewById(R.id.imageView)
        val index:TextView = mItemView.findViewById(R.id.index)
    }
}